<?php
error_reporting(E_ALL^E_NOTICE);
if (empty($_REQUEST['f'])) exit();
$path = pathinfo($_REQUEST['f']);
if (empty($path['basename'])) exit();
$ext = $path['extension'];
if ($ext != 'css' && $ext != 'js') exit();

define('MINI_PATH', substr(dirname(__FILE__), 0,-5));

if(extension_loaded('zlib')){//检查服务器是否开启了zlib拓展
	ob_start('ob_gzhandler');
}
if ($ext == 'css')
	header('Content-Type:text/css;charset=utf-8');
else
	header('Content-Type:application/x-javascript;charset=utf-8');

header('cache-control:must-revalidate');
$offset = 3600*24*7;	//过期时间
$expire = 'Expires:'.gmdate('D, d M Y H:i:s', time() + $offset).' GMT';
header ($expire);
ob_start();
 
//包含你的文件
include(MINI_PATH. ($ext == 'js' ? 'js/' : 'css/') .$path['basename']);
 
if(extension_loaded('zlib')){
	ob_end_flush();//输出buffer中的内容，即压缩后的文件
}
?>